package com.cloud.lan.service.task;

import com.cloud.lan.entity.constant.TagConstant;
import com.cloud.lan.service.ILanTagUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * Created by zhouquan on 2022/4/16.
 */
@Component
@Configuration
@Slf4j
@EnableScheduling
public class LanTagTask {

    @Autowired
    private ILanTagUserService iLanTagUserService;

    /**
     * 每天凌晨执行一次
     */
    @Scheduled(cron = "0 0 0 * * ?")
    private void tagTimeHandle() {
        try {
            iLanTagUserService.timeHandle(TagConstant.TAG_VISIT1MONTH);
            iLanTagUserService.timeHandle(TagConstant.TAG_VISIT2WEEK);
            iLanTagUserService.timeHandle(TagConstant.TAG_USERFAVOURITES);
            log.info("#定时任务.tagTimeHandle.完成");
        } catch (Exception e) {
            log.error("#定时任务.tagTimeHandle.异常", e);
        }
    }

}
